// 匹兹堡睡眠量表配置文件
export const psqiConfig = {
  // 问卷基本信息
  title: '匹兹堡睡眠量表',
  subtitle: 'Pittsburgh Sleep Quality Index (PSQI)',
  description: '评估最近一个月的睡眠质量和睡眠障碍',
  instruction: '下面一些问题是关于您最近一个月的睡眠状况，这仅仅与您的睡眠习惯有关。请选择或填写最符合您近一个月白天和晚上实际情况的选项，并尽可能地做精确回答。',
  version: '1.0',
  
  // 表单分组配置
  sections: {
    basicInfo: {
      title: '被评估人基本信息',
      fields: [
        {
          name: 'patientName',
          label: '姓名',
          type: 'text',
          required: false,
          placeholder: '请输入被评估人姓名（可选）'
        },
        {
          name: 'age',
          label: '年龄',
          type: 'number',
          required: false,
          placeholder: '请输入年龄（可选）',
          min: 0,
          max: 150
        },
        {
          name: 'gender',
          label: '性别',
          type: 'radio',
          required: false,
          options: [
            { value: 'male', label: '男性' },
            { value: 'female', label: '女性' }
          ]
        },
        {
          name: 'diagnosis',
          label: '诊断',
          type: 'text',
          required: false,
          placeholder: '请输入相关诊断（可选）'
        },
        {
          name: 'phone',
          label: '联系电话',
          type: 'tel',
          required: false,
          placeholder: '请输入联系电话（可选）'
        },
        {
          name: 'recordTime',
          label: '评估时间',
          type: 'datetime-local',
          required: false
        },
        {
          name: 'remarks',
          label: '备注',
          type: 'textarea',
          required: false,
          placeholder: '请输入本次评估的备注信息（可选）',
          rows: 3
        }
      ]
    },
    assessment: {
      title: 'PSQI睡眠质量评估',
      description: '请根据最近一个月的睡眠情况如实回答以下问题'
    }
  },
  
  formGroups: [
    
    {
      id: 'sleep_habits',
      title: '睡眠习惯',
      questions: [
        {
          id: 'SL01',
          type: 'time',
          label: 'SL01. 在最近一个月中，您晚上上床睡觉通常是几点钟？',
          required: true,
          placeholder: '请选择时间'
        },
        {
          id: 'SL02',
          type: 'number',
          label: 'SL02. 在最近一个月中，您每晚通常要多长时间才能入睡（从上床到入睡）？',
          required: true,
          placeholder: '请输入分钟数',
          min: 0,
          max: 300,
          unit: '分钟'
        },
        {
          id: 'SL03',
          type: 'time',
          label: 'SL03. 在最近一个月中，您每天早上通常几点钟起床？',
          required: true,
          placeholder: '请选择时间'
        },
        {
          id: 'SL04',
          type: 'number',
          label: 'SL04. 在最近一个月中，您每晚实际睡眠的时间为多少小时？（不等同卧床时间，可以有小数）',
          required: true,
          placeholder: '请输入小时数',
          min: 0,
          max: 24,
          step: 0.5,
          unit: '小时'
        }
      ]
    },
    {
      id: 'sleep_disturbances',
      title: '睡眠干扰',
      description: '在最近一个月中，您是否因下列情况影响睡眠而烦恼，并描述其程度：',
      questions: [
        {
          id: 'SL051',
          type: 'radio',
          label: 'SL051. 入睡困难：不能在30分钟内入睡',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL052',
          type: 'radio',
          label: 'SL052. 夜间易醒或早醒（凌晨醒后不容易再次入睡）',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL053',
          type: 'radio',
          label: 'SL053. 晚上起床上洗手间',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL054',
          type: 'radio',
          label: 'SL054. 晚上睡觉时出现呼吸不畅',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL055',
          type: 'radio',
          label: 'SL055. 晚上睡觉出现响亮的鼾声或咳嗽声',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL056',
          type: 'radio',
          label: 'SL056. 晚上睡觉感到太冷',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL057',
          type: 'radio',
          label: 'SL057. 晚上睡觉感到太热',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL058',
          type: 'radio',
          label: 'SL058. 晚上睡觉做恶梦',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL059',
          type: 'radio',
          label: 'SL059. 晚上睡觉身上出现疼痛不适',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL05X_description',
          type: 'textarea',
          label: 'SL05X. 其他影响睡眠的问题和原因（如有，请说明这个问题）',
          required: false,
          placeholder: '请描述其他影响睡眠的问题'
        },
        {
          id: 'SL05X1',
          type: 'radio',
          label: 'SL05X1. 其他问题的程度',
          required: false,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ],
          dependsOn: 'SL05X_description'
        }
      ]
    },
    {
      id: 'sleep_quality_medication',
      title: '睡眠质量与用药',
      questions: [
        {
          id: 'SL06',
          type: 'radio',
          label: 'SL06. 在最近一个月中，总的来说，您认为自己的睡眠质量',
          required: true,
          options: [
            { value: 0, label: '很好' },
            { value: 1, label: '较好' },
            { value: 2, label: '较差' },
            { value: 3, label: '很差' }
          ]
        },
        {
          id: 'SL07',
          type: 'radio',
          label: 'SL07. 在最近一个月中，您是否要服药物（包括医院和药店购买的药物）才能入睡',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        }
      ]
    },
    {
      id: 'daytime_dysfunction',
      title: '日间功能障碍',
      questions: [
        {
          id: 'SL08',
          type: 'radio',
          label: 'SL08. 在最近一个月中，您是否常常感到困倦，难以保持清醒状态',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        },
        {
          id: 'SL09',
          type: 'radio',
          label: 'SL09. 在最近一个月中，您做事情的精力不足吗',
          required: true,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ]
        }
      ]
    },
    {
      id: 'sleep_partner',
      title: '睡眠伙伴评估',
      questions: [
        {
          id: 'SL10',
          type: 'radio',
          label: 'SL10. 您是否与人同睡一床，或有室友',
          required: true,
          options: [
            { value: 1, label: '没有' },
            { value: 2, label: '同伴在同一房间但不同床' },
            { value: 3, label: '同伴或室友在另一房间' },
            { value: 4, label: '同伴在同一床上' }
          ]
        },
        {
          id: 'SL101',
          type: 'radio',
          label: 'SL101. 有无高声打鼾',
          required: false,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ],
          dependsOn: 'SL10',
          showWhen: [2, 3, 4]
        },
        {
          id: 'SL102',
          type: 'radio',
          label: 'SL102. 睡眠中较长时间的呼吸暂停（呼吸憋气）现象',
          required: false,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ],
          dependsOn: 'SL10',
          showWhen: [2, 3, 4]
        },
        {
          id: 'SL103',
          type: 'radio',
          label: 'SL103. 睡眠中腿部抽动或痉挛',
          required: false,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ],
          dependsOn: 'SL10',
          showWhen: [2, 3, 4]
        },
        {
          id: 'SL104',
          type: 'radio',
          label: 'SL104. 睡眠中出现不能辨认方向或意识模糊的情况',
          required: false,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ],
          dependsOn: 'SL10',
          showWhen: [2, 3, 4]
        },
        {
          id: 'SL10X_description',
          type: 'textarea',
          label: 'SL10X. 是否有其他影响睡眠的特殊情况（如果有，请描述这个问题）',
          required: false,
          placeholder: '请描述其他特殊情况',
          dependsOn: 'SL10',
          showWhen: [2, 3, 4]
        },
        {
          id: 'SL105',
          type: 'radio',
          label: 'SL105. 其他特殊情况的程度',
          required: false,
          options: [
            { value: 0, label: '无' },
            { value: 1, label: '<1次/周' },
            { value: 2, label: '1~2次/周' },
            { value: 3, label: '≥3次/周' }
          ],
          dependsOn: 'SL10X_description',
          showWhen: [2, 3, 4]
        }
      ]
    }
  ],
  
  // PSQI评分组件
  components: {
    // 组件1：主观睡眠质量
    subjective_sleep_quality: {
      name: '主观睡眠质量',
      questions: ['SL06'],
      maxScore: 3
    },
    // 组件2：入睡时间
    sleep_latency: {
      name: '入睡时间',
      questions: ['SL02', 'SL051'],
      maxScore: 3,
      calculation: 'custom' // 需要特殊计算
    },
    // 组件3：睡眠时间
    sleep_duration: {
      name: '睡眠时间',
      questions: ['SL04'],
      maxScore: 3,
      calculation: 'custom' // 需要特殊计算
    },
    // 组件4：睡眠效率
    sleep_efficiency: {
      name: '睡眠效率',
      questions: ['SL01', 'SL03', 'SL04'],
      maxScore: 3,
      calculation: 'custom' // 需要特殊计算
    },
    // 组件5：睡眠干扰
    sleep_disturbances: {
      name: '睡眠干扰',
      questions: ['SL052', 'SL053', 'SL054', 'SL055', 'SL056', 'SL057', 'SL058', 'SL059', 'SL05X1'],
      maxScore: 3,
      calculation: 'sum_then_convert' // 求和后转换
    },
    // 组件6：催眠药物的使用
    sleep_medication: {
      name: '催眠药物的使用',
      questions: ['SL07'],
      maxScore: 3
    },
    // 组件7：日间功能障碍
    daytime_dysfunction: {
      name: '日间功能障碍',
      questions: ['SL08', 'SL09'],
      maxScore: 3,
      calculation: 'custom' // 需要特殊计算
    }
  },
  
  // 睡眠质量等级
  qualityLevels: {
    good: {
      range: [0, 5],
      label: '睡眠质量好',
      description: 'PSQI总分≤5分，睡眠质量良好',
      color: '#52c41a'
    },
    poor: {
      range: [6, 21],
      label: '睡眠质量差',
      description: 'PSQI总分>5分，睡眠质量较差，建议关注睡眠问题',
      color: '#ff4d4f'
    }
  },
  
  // 界面文本配置
  ui: {
    buttons: {
      previous: '上一步',
      next: '下一步',
      submit: '提交评估',
      export: '导出结果',
      restart: '重新评估',
      backToHome: '返回首页',
      home: '返回首页',
      settings: '设置'
    },
    messages: {
      validationError: '请完成所有必填项目',
      submitSuccess: '评估提交成功！',
      submitError: '提交失败，请重试',
      exportSuccess: '结果导出成功！',
      exportError: '导出失败，请重试'
    },
    placeholders: {
      name: '请输入姓名',
      age: '请输入年龄',
      time: '请选择时间',
      number: '请输入数字',
      textarea: '请输入详细描述'
    }
  },
  
  // 设置页面配置
  settings: {
    title: '设置',
    description: 'PSQI问卷设置选项'
  },

  // 导出设置
  export: {
    filename: 'PSQI睡眠质量评估结果',
    includeCharts: true,
    includeRecommendations: true,
    title: '导出结果'
  }
};

export default psqiConfig;